package com.zlq.cn.service.lovers;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zlq.cn.bootstrap.SignApiBootstrap;
import com.zlq.cn.entity.LoversAnniversaryDay;
import com.zlq.cn.entity.User;
import com.zlq.cn.mapper.lovers.LoversAnniversaryDayMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Set;

/**
 * <p>
 * 纪念日 服务实现类
 * </p>
 *
 * @author zhoucl
 * @since 2022-05-08
 */
@Service
public class LoversAnniversaryDayService extends ServiceImpl<LoversAnniversaryDayMapper, LoversAnniversaryDay> {

    @Resource
    private LoversBindUserService loversBindUserService;

    public Page<LoversAnniversaryDay> pageAnniversaryDay(Page<LoversAnniversaryDay> page) {
        User user = SignApiBootstrap.requestUser();
        Set<Integer> bindUserIds = loversBindUserService.getBindUserIds();
        bindUserIds.add(user.getId());
        return super.lambdaQuery()
                .in(LoversAnniversaryDay::getUserId, bindUserIds)
                .page(page);
    }
}
